package com.pwt.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi userApi(){
        String[] paths = { "/**" };
        String[] packagedToMatch = { "com.pwt.controller.permission" };
        return GroupedOpenApi.builder().setGroup("权限管理")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean GroupedOpenApi settingApi() {
        String[] paths = { "/**" };
        String[] packagedToMatch = { "com.pwt.controller.basicsetting" };
        return GroupedOpenApi.builder().setGroup("设置")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean GroupedOpenApi watchApi() {
        String[] paths = { "/**" };
        String[] packagedToMatch = { "com.pwt.controller.watch" };
        return GroupedOpenApi.builder().setGroup("监控")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean GroupedOpenApi CrustalLusApi() {
        String[] paths = { "/**" };
        String[] packagedToMatch = { "com.pwt.controller.crustallus" };
        return GroupedOpenApi.builder().setGroup("能力")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean GroupedOpenApi LargeScreenApi() {
        String[] paths = { "/**" };
        String[] packagedToMatch = { "com.pwt.controller.largescreen" };
        return GroupedOpenApi.builder().setGroup("大屏")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("青山API")
                        .version("1.0")
                        .description( "青山API")
                        .termsOfService("http://doc.xiaominfo.com")
                        .license(new License().name("Apache 2.0")
                                .url("http://doc.xiaominfo.com")));
    }
}